
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
	</head>
	<body>
		<div id="app">
			<div>
				<div>
					<p v-for="(item, index) in showdetailList">
					  <span>{{item.title}}</span>
					  <span>{{item.name}}</span>
					</p>
				</div>
				<div v-if="detailList.length > 6" v-on:click="changeFoldState">
					 <span>{{brandFold?'展开':'收起'}}</span>
				 </div>
			</div>
			<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
			<script type="text/javascript">
			new Vue({
				el: '#app',
				data: {
					brandFold: true,
					detailList: []
				},
				mounted(){
					this.mocData();
				},
				computed: {
				  showdetailList: {
					get: function () {
						if (this.brandFold){
							if (this.detailList.length < 7) {
								return this.detailList
							}
							let newArr = [];
							for (var i = 0; i < 6; i++) {
								let item = this.detailList[i]
								newArr.push(item)
							}
							return newArr
						}
					  return this.detailList
					},
					set: function (val) {
						this.showdetailList = val
					}
				  }
				},
				methods: {
					changeFoldState() {
						this.brandFold = !this.brandFold
					},
					mocData() {
					  var items = ['Dr.Ci:Labo城野医生', '日本', '控油  收敛毛孔', '任何肤质', '面部', '化妆水', '任何肤质', '面部', '化妆水']
					  var lists = ['商品品牌', '品牌国', '功能', '适合肤质', '适用部位', '产品类型', '商品品牌', '品牌国', '功能']
					  for (var i = 0; i < items.length; i++) {
						 let item = {title: lists[i], name: items[i]}
						 this.detailList.push(item)
					  }
					  console.log(this.detailList)
					}
				}
			})
		</script>
	</body>
</html>